package com.ruoyi.project.kafka;

import java.util.Random;

public class KafkaProducerTest {
    public static void main(String[] args) throws InterruptedException {
        //生产者发送消息
//        KafkaUtils.KafkaStreamServer kafkaStreamServer =  KafkaUtils.bulidServer().createKafkaStreamServer("192.168.33.207", 9092);
        KafkaUtils.KafkaStreamServer kafkaStreamServer =  KafkaUtils.bulidServer().createKafkaStreamServer("218.78.18.147", 7004);
        int i=0;
        while (i<10) {
            String msg = "Hello," + new Random().nextInt(100);
            kafkaStreamServer.sendMsg("devices/156456461325/events", msg);
            i++;
            Thread.sleep(100);
        }
        kafkaStreamServer.close();
        System.out.println("发送结束");
    }
}
